# coding=utf-8
import urllib,urllib2,cookielib
from BeautifulSoup import BeautifulSoup
myCookie = urllib2.HTTPCookieProcessor(cookielib.CookieJar());
opener = urllib2.build_opener(myCookie)
post_data = {
    'email':'**********',
    'password':'********',
    'origURL':'http://www.renren.com/Home.do',
    'domain':'renren.com'
}
req = urllib2.Request('http://www.renren.com/PLogin.do', urllib.urlencode(post_data))
html_src = opener.open(req).read()
try:
    html_src = html_src.decode('utf-8')
except:
    html_src = html_src.decode('gbk')
    
parser = BeautifulSoup(html_src)
article_list = parser.find('div','feed-list').findAll('article')
for my_article in article_list:
    state = []
    for my_tag in my_article.h3.contents:
        factor = my_tag.string
        if factor != None:
            factor = factor.replace(u'/xa0','')
            factor = factor.strip(u'/r/n')
            factor = factor.strip(u'/n')
            state.append(factor)
            print ' '.join(state)
